<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>事件</title>
		<style type="text/css">
			input {
				font-size: 26px;
				margin-top: 20px;
			}

			body {
				background-image: url(img/six/grassland.png);
			}

			#mytank {
				position: absolute;
				left: 10px;
				top: 100px
			}
		</style>
	</head>
	<body>
		<input id="btn1" onclick="show1()" type="button" value="按钮一" />
		<input id="btn2" ondblclick="show2()" type="button" value="按钮二" />
		<input id="btn3" onclick="show3()" type="button" value="按钮三" />
		<hr />
		<img id="mytank" src="img/six/right.png" />
		<script type="text/javascript">
			//
			//179000646唐渝
			//
			var mytank = document.getElementById('mytank');
			window.addEventListener(
				'keydown',
				function(e) {
					console.log(e.keyCode);
					if (e.keyCode == 39) {
						mytank.style.left = (mytank.offsetLeft + 10) + 'px';
					} else if (e.keyCode == 37) {
						mytank.style.left = (mytank.offsetLeft - 10) + 'px';
					} else if (e.keyCode == 38) {
						mytank.style.top = (mytank.offsetTop - 10) + 'px';
					} else if (e.keyCode == 40) {
						mytank.style.top = (mytank.offsetTop + 10) + 'px';
					}
				});

			function show1() {
				alert("JavaScript事件测试一");
			}

			function show2() {
				alert("按钮二测试");
			}

			function show3() {
				document.getElementById("btn3").style.color = "#ff0000";
				document.getElementById("btn3").style.backgroundColor = "#ffffff";
				alert("JavaScript事件测试三");
			}
			//禁用网页右键菜单
			if (window.Event)
				document.captureEvents(Event.MOUSEUP);

			function nocontextmenu() {
				event.cancelBubble = true
				event.returnValue = false;
				return false;
			}

			function norightclick(e) {
				if (window.Event) {
					if (e.which == 2 || e.which == 3)
						return false;
				} else if (event.button == 2 || event.button == 3) {
					event.cancelBubble = true
					event.returnValue = false;
					return false;
				}

			}
			document.oncontextmenu = nocontextmenu; // for IE5+
			document.onmousedown = norightclick; //for all others
		</script>
	</body>
</html>
